<template>
	<view>
		<uni-list>
			<template v-for="(item, index) in list.list" >
				<uni-list-item link  @click="onClick(item)" >
				   <template slot="header">
				             <image class="slot-image" :src="item.image" mode="widthFix"></image>
				    </template>
					
					<template slot="body" class="slot-box">
						 <view class="slot-text" >
							 <span v-if="item.content">{{item.content}}</span>
						 </view>
						 <view class="slot-time" >
							 <span >{{ $wanlshop.timeToDate(item.createtime) }}</span>
						 </view>
						<!-- <view class="slot-text-note">
							 <span>{{item.content}}</span>
						 </view> -->
						 
					</template>
				</uni-list-item>
			</template>
		</uni-list>
		<wanl-live-play v-if="playUrl" :screenHeight="screenHeight" :screenWidth="screenWidth" :source="playUrl" />
	</view>
</template>

<script>
	var system = uni.getSystemInfoSync();
	import wanlLivePlay from '@/components/wanl-live/play';
	export default {
		components: {
			wanlLivePlay,
		},
		data() {
			return {
				screenHeight: system.screenHeight,
				screenWidth: system.screenWidth,
				playUrl: '',
				list:{
					loadingType: 'more',
					current_page: 1,
					list:[],
				},
			}
		},
		onLoad() {
			this.loadData();
		},
		methods: {
			onClick(item){
				console.log(item)
				this.playUrl = item.recordurl
			},
			loadData(){
				let index = this.tabCurrentIndex;
				let navItem = this.list;
				
				//判断是否最后一页
				if (navItem.loadingType == 'noMore') {
					return;
				}
				//防止重复加载
				if (navItem.loadingType === 'loading') {
					return;
				}
				navItem.loadingType = 'loading';
				// 获取列表
				this.$api.get({
					url: '/wanlshop/live/liveList',
					data: {
						state: 2,//2=直播结束
						page: navItem.current_page
					},
					success: res => {
						console.log(res)
						navItem.current_page = res.current_page; //当前页码
						if (res.last_page === res.current_page) {
							navItem.loadingType = 'noMore';
						} else {
							navItem.loadingType = 'more';
							navItem.current_page++;
						}
						let list = res.data;
						list.forEach(item => {
							navItem.list.push(item);
						});
						//loaded新字段用于表示数据加载完毕，如果为空可以显示空白页
						this.$set(navItem, 'loaded', true);
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.slot-image{
		width: 200rpx;
		margin-right: 30rpx;
	}
	.slot-box{
		.slot-text{
			font-size: 30rpx;
			padding-bottom:130rpx;
		}
		.slot-text-note{
			font-size: 22rpx;
			margin-bottom: -10rpx;
		}
		.slot-time{
			font-size: 22rpx;
		}
	}
	
</style>
